/********************************************************************
	Rhapsody	: 7.5 
	Login		: KBE
	Component	: DefaultComponent 
	Configuration 	: CodeConfig
	Model Element	: SimulatorReactorImplementation
//!	Generated Date	: Fri, 7, Sep 2012  
	File Path	: DefaultComponent\CodeConfig\SimulatorReactorImplementation.cpp
*********************************************************************/

//## auto_generated
#include "SimulatorReactorImplementation.h"
//## link itsStubSynchronousEventDemultiplexer
#include "StubSynchronousEventDemultiplexer.h"
//## dependency EHANDLE
#include "EHANDLE.h"
//## package Default

//## class SimulatorReactorImplementation
SimulatorReactorImplementation::~SimulatorReactorImplementation() {
    cleanUpRelations();
}

void SimulatorReactorImplementation::handleEvents(int time) {
    //#[ operation handleEvents(int)
    
    Event_Type eventType; 
    EHANDLE h;
    
    // Prototype test for simulating 3 events
    for (int i = 0; i < 3; i++)
    {   
    	
    	eventType = itsStubSynchronousEventDemultiplexer->SimulateEvents(h); 
        	
       	//std::list<EventHandler*>::const_iterator iter;  
       	//std::map<Event_Type, EventHandler*>::const_iterator iter;
        //iter = itsEventHandler.begin(); 
        // while (iter != itsEventHandler.end()){ 
        //     EventHandler *eh = *iter;         
        
        EventHandler *eh = getItsEventHandler(eventType);
    	switch (eventType)
    	{
    		case ALARM_EVENT:  
    			eh->handleAlarm(h);
    		break;
    		case PATIENT_EVENT:
    			eh->handlePatient(h);
    		break;
    		case LOG_EVENT:
    			eh->handleLog(h);
    		break;
    		default:
    		break;
    	}
      	//	iter++; 
       	//}
     	      
    };
    //#]
}

StubSynchronousEventDemultiplexer* SimulatorReactorImplementation::getItsStubSynchronousEventDemultiplexer() const {
    return itsStubSynchronousEventDemultiplexer;
}

void SimulatorReactorImplementation::cleanUpRelations() {
    if(itsStubSynchronousEventDemultiplexer != NULL)
        {
            itsStubSynchronousEventDemultiplexer = NULL;
        }
}

SimulatorReactorImplementation::SimulatorReactorImplementation() {
    itsStubSynchronousEventDemultiplexer = NULL;
    //#[ operation SimulatorReactorImplementation()
    itsStubSynchronousEventDemultiplexer = new StubSynchronousEventDemultiplexer();
    //#]
}

/*********************************************************************
	File Path	: DefaultComponent\CodeConfig\SimulatorReactorImplementation.cpp
*********************************************************************/
